package lyp;

import java.util.Arrays;
import java.util.Scanner;

public class Demo3 {
	public static void main(String[] args) {
		int[] num=new int[5];
		num[0]=10;
		num[1]=8;
		num[2]=6;
		num[3]=4;
		num[4]=2;
		System.out.println("原数组："+Arrays.toString(num));
		Scanner s=new Scanner(System.in);
		System.out.println("输入插入数：");
		int a=s.nextInt();
		int index=0,i;
		for (i = 0; i < num.length; i++) {
			if (a>num[i]) {
				index=i;
				break;
			}
		}
		int[] num2=new int[num.length+1];
		for (int j = 0; j < index; j++) {
			num2[j]=num[j];
		}
		for (int j = 5; j > index; j--) {
			num2[j]=num[j-1];
		}
		num2[index]=a;
		System.out.println("新数组："+Arrays.toString(num2));
	}
}